package service;

import java.util.List;

import util.DatabaseConnection;
import model.User;
import dao.Userdao;
import dao.UserdaoImp;


public class UserServiceImp implements  UserService {

	private UserdaoImp udi = null;
	public UserServiceImp(){
		udi=new UserdaoImp();//获取UserDaoImp方法
	}	
	public boolean CreateUser(User user) throws Exception {
		
		return udi.doCreate(user);
	}


	public boolean deleteUser(String userid) throws Exception {
	
		return udi.dodelete(userid);
	}


	public boolean updateUser(User user) throws Exception {
		
		return udi.doupdate(user);
	}

	
	public List<User> findAll() throws Exception {
	
		return udi.findAll();
	}


	public String findUserByID(String userid) throws Exception {
	
        User user = udi.findUserByID(userid);
        
		return user.getpassword();
	}


	public boolean finduserByID(String userid) throws Exception {
	
		User user = udi.findUserByID(userid);
		if(user==null)
		     return false;
		else
			return true;	
	}

    public User findAUserByID(String userid) throws Exception {
	
    	return udi.findUserByID(userid);
	
	}

}